package com.lazy.app.ui.act;

import android.os.Bundle;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.Fragment;

import com.lazy.app.R;
import com.lazy.app.databinding.ActivityRegisterBinding;
import com.lazy.app.ui.fragment.RegisterFragment;
import com.zndroid.base.simples.SimplePresenter;
import com.zndroid.base.ui.common.CommonActivity;

import java.util.List;

public class RegisterActivity extends CommonActivity<ActivityRegisterBinding, SimplePresenter> {
    @Override
    protected ActivityRegisterBinding onSupplyViewBinding(@NonNull LayoutInflater layoutInflater) {
        return ActivityRegisterBinding.inflate(layoutInflater);
    }

    @Override
    protected int onSupplyStatusBarColor() {
        return ResourcesCompat.getColor(getResources(), R.color.white, getTheme());
    }

    @Override
    protected void doOnCreate(@Nullable Bundle savedInstanceState) {
        super.doOnCreate(savedInstanceState);

        /*android:configChanges="orientation|keyboard|screenSize" 防止横竖屏切换导致activity重启 也可以判断savedInstanceState为不为null*/
        Fragment registerFragment = new RegisterFragment();
        getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, registerFragment).commitAllowingStateLoss();
    }

    @Override
    protected void doOnDestroy() {
        super.doOnDestroy();

        List<Fragment> fragments = getSupportFragmentManager().getFragments();
        for (Fragment it :
                fragments) {
            getSupportFragmentManager().beginTransaction().remove(it);
        }
    }
}
